//
//  HEServerDetailsInfoCell.m
//  HealthFamily
//
//  Created by 吴欧 on 2020/11/17.
//  Copyright © 2020 honglutec. All rights reserved.
//

#import "HEServerDetailsInfoCell.h"

@interface HEServerDetailsInfoCell ()

@property (nonatomic, strong) QMUIButton *btn;
@property (nonatomic, strong) UILabel *priceLb;

@property (nonatomic, strong) UIView *warp;

@end

@implementation HEServerDetailsInfoCell

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self initUI];
    }
    return self;
}

- (void)initUI {
    
    UIView *warp2 = [UIView new];
    [self.contentView addSubview:warp2];
    warp2.layer.shadowColor = [UIColor colorWithRed:13/255.0 green:98/255.0 blue:218/255.0 alpha:0.08].CGColor;
    warp2.layer.shadowOffset = CGSizeMake(0,5);
    warp2.layer.shadowOpacity = 1;
    warp2.layer.shadowRadius = 6;

    [warp2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView);
        make.left.equalTo(self.contentView);
        make.right.equalTo(self.contentView);
        make.bottom.equalTo(self.contentView);
    }];
    
    UIView *warp = [UIView new];
    _warp = warp;
    warp.backgroundColor = KWhiteColor;
    [warp2 addSubview:warp];
    warp.layer.masksToBounds = YES;
    warp.layer.cornerRadius = 6;
    
    [warp mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(warp2).mas_offset(0);
        make.left.equalTo(warp2).mas_offset(0);
        make.right.equalTo(warp2).mas_offset(-0);
        make.bottom.equalTo(warp2).mas_offset(-0);
    }];

    _btn = [[QMUIButton alloc] init];
    _btn.userInteractionEnabled = NO;
    _btn.adjustsButtonWhenDisabled = NO;
    _btn.adjustsButtonWhenHighlighted = NO;
    _btn.imagePosition = QMUIButtonImagePositionTop;// 将图片位置改为在文字下方
    _btn.tintColorAdjustsTitleAndImage = CNavSubTitleColor;
    _btn.adjustsImageTintColorAutomatically = NO;
    _btn.spacingBetweenImageAndTitle = 10;
    [_btn setImage:UIImageMake(@"pay_zfb") forState:UIControlStateNormal];
    [_btn setTitle:@"图文咨询" forState:UIControlStateNormal];
    _btn.titleLabel.font = DYFont(15);
    [warp addSubview:_btn];
    
    [_btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(warp).mas_offset(10);
        make.left.equalTo(warp).mas_offset(0);
        make.right.equalTo(warp).mas_offset(-0);
    }];
    
    _priceLb = [UILabel new];
    _priceLb.text = @"￥30.0/次";
    _priceLb.font = DYBlodFont(15);
    _priceLb.textColor = CPriceColor;
    _priceLb.textAlignment = NSTextAlignmentCenter;
    [warp addSubview:_priceLb];
    
    [_priceLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_btn.mas_bottom).mas_offset(10);
        make.left.equalTo(warp);
        make.right.equalTo(warp);
        make.bottom.equalTo(warp.mas_bottom).mas_offset(-10);
    }];
}

- (void)setModel:(HEDoctorInfoModel *)model {
    _model = model;
    
    [_btn setImage:UIImageMake(model.icon) forState:UIControlStateNormal];
    [_btn setTitle:model.server_name forState:UIControlStateNormal];
    
    _priceLb.text = [NSString stringWithFormat:@"￥%@/%@", [NSDecimalNumber rounding:model.price afterPoint:2], [DYTools IsNotNull:model.unit]];
    
    if (model.isChoose) {
        _warp.backgroundColor = KHexColor(@"E8F2FE");
        _warp.qmui_borderPosition = QMUIViewBorderPositionBottom | QMUIViewBorderPositionTop| QMUIViewBorderPositionLeft | QMUIViewBorderPositionRight;
        _warp.qmui_borderWidth = 1;
        _warp.qmui_borderColor = CNavBgColor;
    }else {
        _warp.backgroundColor = KWhiteColor;
        _warp.qmui_borderWidth = 0;
    }
}

@end
